package com.hz.userservice.controller;

import com.hz.apiservice.model.dto.TeacherDTO;
import com.hz.apiservice.model.request.ApiResponse;
import com.hz.userservice.service.TeacherService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
public class TeacherController {
    @Resource
    TeacherService teacherService;
    @GetMapping("/all-teacher")
    public String allTeachers(){
        return ApiResponse.ok(teacherService.allTeachers());
    }
    @GetMapping("/teacher-info")
    public String getTeacherInfo(Integer teacherId){
        TeacherDTO teacherDTO=teacherService.findTeacherById(teacherId);
        return teacherDTO!=null?ApiResponse.ok(teacherDTO):ApiResponse.resNotFound();
    }
}
